#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QSystemTrayIcon>
#include <QCloseEvent>
#include <QScopedPointer>

class QMenu;
class QAction;
class QToolBar;
class QDockWidget;
class LogWidget;
class ConnectDialog;

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

protected:
    void closeEvent(QCloseEvent *event) override;

private slots:
    // 文件菜单槽函数
    void newConnection();
    void disconnect();
    void exitApplication();
    
    // 视图菜单槽函数
    void toggleFullscreen();
    void toggleLogPanel();
    
    // 工具菜单槽函数
    void preferences();
    
    // 帮助菜单槽函数
    void about();
    void aboutQt();

private:
    void createActions();
    void createMenus();
    void createToolBars();
    void createStatusBar();
    void createDockWindows();
    void createTrayIcon();
    
    void readSettings();
    void writeSettings();
    
    // 菜单
    QMenu *fileMenu;
    QMenu *viewMenu;
    QMenu *toolsMenu;
    QMenu *helpMenu;
    
    // 工具栏
    QToolBar *mainToolBar;
    
    // 动作
    QAction *newConnectionAction;
    QAction *disconnectAction;
    QAction *exitAction;
    QAction *fullscreenAction;
    QAction *logPanelAction;
    QAction *preferencesAction;
    QAction *aboutAction;
    QAction *aboutQtAction;
    
    // 系统托盘
    QSystemTrayIcon *trayIcon;
    QMenu *trayIconMenu;
    
    // 停靠窗口
    QDockWidget *logDockWidget;
    LogWidget *logWidget;
    
    // 连接对话框
    ConnectDialog *connectDialog;
};

#endif // MAINWINDOW_H